<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <div class="active"><input type="checkbox">全选</div>
        <div>
            <ul>
                <li><input name="Snum" class="divone" type="checkbox">张三</li>
                <li><input name="Snum" class="divtwo" type="checkbox">李四</li>
                <li><input name="Snum" class="divthree" type="checkbox">王五</li>
            </ul>
        </div>
    </div>

    <script>
        let check_val = [];   //---定义一个数组
        //---循环name="Snum"的input标签
        $('input[name="Snum"]:checked').each(function () {
            //---将该标签的value值追加到数组中
            check_val.push($(this).val());
        });
        check_val;
        $("input[name='Snum'][value=" + data + "]").attr("checked", true)
        //如果data为2  则默认勾选bb

        //如果data有多个值也可以写循环进行勾选
        for (i in data) {
            $("input[name='Snum'][value=" + data[i] + "]").attr("checked", true)
        }
    </script>
</body>

</html>